#include "../src/common.h"
#include "../src/font.hpp"

using namespace xege;

int main () {

	WINDOW window (800, 600);
	FONT font ("./res/test.ttf", 52);
	SDL_Event gEvent;
	POINT mouse {0};
	bool windowIsRun = true;

	char* s = new char [256];
	BUTTON button (window, 300, 200, 100, 100);
	while (windowIsRun) {
		// while (SDL_PollEvent (&gEvent)) {
			switch (SDL_PollEvent (&gEvent); gEvent.type) {
			case SDL_QUIT:
				windowIsRun = false; 
				window.close ();
				SDL_Quit ();
			break;
			case SDL_MOUSEBUTTONDOWN: 

			break;
			case SDL_MOUSEBUTTONUP: 

			break;
			// case sdl
			default: 

			break;
			}

			SDL_GetMouseState (&mouse.x, &mouse.y);
			// SDL_Log ("x: %4d\ny: %4d", x, y);
			sprintf (s, "x: %4d  y: %4d", mouse.x, mouse.y);
			button.show (&gEvent);
			// font.drawFont (window, 100, 100, "Hello World");
			
			// TTF_Init ();
			// TTF_Font* font = TTF_OpenFont ("./res/test.ttf", 24);
			// if (!font) SDL_Log ("load font error: %s", TTF_GetError ());
			IMAGE pic (window, font.renderFont (s));
			pic.putImage (100, 100);
			window.updateTexture ();
			// SDL_Log ("fuck");
			window.update ();
			window.clear ();
			SDL_Delay (1.0/60*1000);
		// }
	}




	return 0;

}